<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header('监测项详情')" />
</head>
<body>
<div class="container-div">
    <input name="psId" autocomplete="off" id="psId"  class="form-control" type="hidden" th:value="${itemInfo.id}" >
    <div class="row">
        <div th:include="biz/item/include::detail-header"></div>
    </div>
</div>
<div th:include="include::footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "biz/unit";
    var editFlag = [[${@permission.hasPermi('biz:unit:edit')}]];
    var removeFlag = [[${@permission.hasPermi('biz:unit:remove')}]];
    var types = [[${@dict.getType('sys_normal_disable')}]];
    var datas = [[${@dict.getType('biz_is_delete')}]];

    $(function() {
        var options = {
            id: "unit-table",
            url: prefix + "/list/"+[[${itemInfo.id}]],
            createUrl: prefix + "/add",
            //  updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "监测项指标",
            columns: [{
                checkbox: true
            },
                {
                    field : 'id',
                    title : 'ID'
                },
                {
                    field : 'pumpCode',
                    title : '所属泵站'
                },
                {
                    field : 'itemName',
                    title : '监测项名称'
                },
                {
                    field : 'sblxName',
                    title : '设备类型名称'
                },
                {
                    field : 'sbName',
                    title : '设备名称'
                },
                {
                    field : 'unitZh',
                    title : '单位中文'
                },
                {
                    field : 'unitFlag',
                    title : '单位符号'
                },
                {
                    field : 'fzUp',
                    title : '上限阀值'
                },
                {
                    field : 'fzDown',
                    title : '下限阀值'
                },
                {
                    field: 'isDeleted',
                    title: '删除标志',
                    align: 'center',
                },
                {
                    field: 'isValid',
                    title: '是否有效',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    field: 'isUpdownWarning',
                    title: '是否需要上下限报警',
                    align: 'center',
                    formatter: function(value, row1, index) {
                        return statusTools(row1);
                    }
                },
                {
                    field: 'isFlagWarning',
                    title: '是否信号报警',
                    align: 'center',
                    formatter: function(value, row2, index) {
                        return statusTools(row2);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detailTab(\'' + row.id + '\')"><i class="fa fa-file-text"></i>查看详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function statusTools(row) {
        if (row.isValid == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
        }
    }
    function statusTools(row1) {
        if (row1.isUpdownWarning == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row1.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row1.id + '\')"></i> ';
        }
    }

    function statusTools(row2) {
        if (row2.isFlagWarning == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row2.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row2.id + '\')"></i> ';
        }
    }

    function disable(id) {
        $.modal.confirm("确认要停用吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
        })
    }

    function enable(id) {
        $.modal.confirm("确认要启用吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
        })
    }

</script>
</body>
</html>
